package com.vrv.common.resolver;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 分页对象
 *
 * @author 曹保利
 *
 */
public class Page implements Serializable {

    /** SeriUID */
    private static final long serialVersionUID = -2298491666724724856L;

    private List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

    private int pageSize = 20;

    private int pageNumber = 0;

    private int totalCount = 0;

    public Page(Response response) {
        this.totalCount = response.getTotalRecords();
        this.result = response.getRecords();
    }

    public Page(Response response, int pageNumber) {
        this(response);
        this.pageNumber = pageNumber;
    }

    public Page(Response response, int pageSize, int pageNumber) {
        this(response);
        this.pageSize = pageSize;
        this.pageNumber = pageNumber;
    }

    public boolean hasNextPage() {
        if (totalCount <= pageSize * (pageNumber + 1)) {
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }

    public boolean hasPrePage() {
        if (pageNumber > 0) {
            return true;
        }
        return false;
    }

    public List<Map<String, Object>> getResult() {
        return result;
    }

    public void setResult(List<Map<String, Object>> result) {
        this.result = result;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

}
